<template>
  <div>
    <el-table
      :data="listdata"
      style="width: 100%"
      row-key="id"
      border
      lazy
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column prop="id" label="用户编号" width="100"></el-table-column>
      <el-table-column prop="username" label="用户名"></el-table-column>
      <el-table-column prop="rolename" label="所属角色"></el-table-column>
      <el-table-column prop="a" label="状态">
        <template slot-scope="scope">
        <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
        <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="b" label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="change(scope.row.uid)">修改</el-button>
          <el-button type="danger" @click="del(scope.row.uid)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      :page-size="5"
      :total="obj.total"
      class="fr"
      @current-change="currentChange"
    ></el-pagination>
  </div>
</template>

<script>
import { reqUserdelete, reqUserinfo } from "../../../request/api.js";
import {mapGetters,mapActions} from "vuex"
export default {
  props: ["listdata", "obj", "Userlistdata"],
  data() {
    return {};
  },
  methods: {
    currentChange(page) {
      this.Userlistdata.page = page;
      this.$emit("refresh");
    },
    //   修改
    change(uid) {
      this.$emit("change", uid);
      this.obj.isshow = true;
      this.obj.isadd = false;
    },
    del(uid) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          reqUserdelete({ uid: uid }).then(res => {});
          this.$emit("refresh");
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  },
  mounted() {
      // console.log(this.listdata);
  }
};
</script>

<style>
</style>